<template>
  <div class='container'>
    <el-dialog
      v-if="dialogVisible"
      title="题目预览"
      :visible="dialogVisible"
      @close="onClose"
      width="30%">
      <div>
        <el-row>
          <el-col :span="6">【题型】: {{ row.questionType }}</el-col>
          <el-col :span="6">【编号】: {{ row.id }}</el-col>
          <el-col :span="6">【难度】: {{ row.difficulty }}</el-col>
          <el-col :span="6">【标签】: {{ row.tags }}</el-col>
          <el-col :span="6">【学科】: {{ row.subjectName }}</el-col>
          <el-col :span="6">【目录】: {{ row.directoryName }}</el-col>
          <el-col :span="6">【方向】: {{ row.direction }}</el-col>
        </el-row>
        <el-row class="row-border">
          <el-col>【题干】:
            <p class="question-content">{{ row.question }}</p>
            <!-- 选择题 -->
            <div v-if="row.questionType !== '简答'">
              <div>{{ row.questionType + '题 选项：(以下选中的选项为正确答案)'}}</div>
              <div class="select-option" v-for="item in row.options" :key="item.id">
                <el-checkbox :checked="item.isRight === 1">{{ item.title }}</el-checkbox>
              </div>
            </div>
          </el-col>
        </el-row>
        <el-row class="row-border">
          <el-col>【参考答案】:
            <el-button type="danger" size="small" @click="openVideo(row.videoURL)">视频答案预览</el-button>
            <div v-show="showVideo" class="video">
              <video :src="row.videoURL" controls width="400" height="300"></video>
            </div>
          </el-col>
        </el-row>
        <el-row class="row-border">
          <el-col>【答案解析】: {{ row. answer }}</el-col>
        </el-row>
        <el-row class="row-border">
          <el-col>【题目备注】: {{ row.remarks }}</el-col>
        </el-row>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="onClose">关闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>

export default {
  data () {
    return {
      showVideo: false
    }
  },
  props: {
    dialogVisible: {
      type: Boolean,
      required: true
    },
    row: {
      type: Object,
      required: true
    }
  },
  created () {
  },
  methods: {
    // 关闭对话框
    onClose () {
      this.showVideo = false
      this.$emit('update:dialogVisible', false)
    },
    // 打开视频
    openVideo (bol) {
      if (bol) {
        this.showVideo = true
      } else {
        this.$message.error('暂未视频')
      }
    }
  }
}
</script>

<style scoped lang='less'>
/deep/ .el-dialog {
  width: 900px !important;
  .el-row {
    padding: 10px 0;
    .el-col {
      padding: 10px 0;
    }
  }
  .row-border {
    border-top: 1px solid #606266;
  }
  .question-content {
    color: blue;
  }
  .select-option {
    margin-top: 10px;
  }
  .el-checkbox {
    pointer-events: none;
  }
  .video {
    margin-top: 10px;
  }
}
</style>
